package com.eqxiu.ieditor.weixin.event;

import java.util.Map;

/**
 * 
 * @description 微信事件处理
 * @author ranger
 * @date Aug 7, 2017
 */
public abstract class AbstractEventHandler implements EventHandler {

	public String getFromUser(Map<String, String> root) {
		return root.get("FromUserName");
	}

	public String getToUser(Map<String, String> root) {
		// 获取接收方
		return root.get("ToUserName");
	}

	@Override
	public String handleEvent(Map<String, String> root) {
		String event = root.get("Event");

		if (canHandle(event)) {
			return doHandle(root);
		}
		return "";

	}

	/**
	 * 
	 */
	public abstract boolean canHandle(String eventType);

	/**
	 * 
	 * @description //TODO 设计说明
	 * @author ranger
	 * @date Aug 7, 2017
	 * @modified by xxx 修改说明
	 * @param root
	 * @return
	 */
	public abstract String doHandle(Map<String, String> root);

}
